package org.outlook.xnotepad.command.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class TimeStampCommandAction implements CommandAction {

	private SimpleDateFormat sdf;
	final String prefix = "%sysdate%[";

	public TimeStampCommandAction(String text) throws Exception {
		String str = text.substring(text.indexOf(prefix)+prefix.length(), text.length()-1);
		sdf = new SimpleDateFormat(str);
	}

	@Override
	public String getValue(int index) {
		return sdf.format(Calendar.getInstance().getTime());
	}

}